package com.cong.juc.thread;

import java.util.concurrent.*;

/**
 * @author cong
 * <p>
 * created on 2021/3/31 下午1:59
 */
public class CallableDemo {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        MyCallable callable = new MyCallable();
        FutureTask<Integer> futureTask = new FutureTask<>(callable);
        new Thread(futureTask).start();
        while (futureTask.isDone()){
            Integer i = futureTask.get();
            System.out.println(i);
        }
//        ExecutorService pool = Executors.newFixedThreadPool(3);
//        Future<Integer> future = pool.submit(callable);
//        Integer integer = future.get();
    }
}
